<template>
    <div>
      <div class="qaq" style="width:1000px;margin:20px auto;">
           <p style="font-size:18px">问题描述 :  <span>我碰到了问题,我碰到了问题,我碰到了问题,我碰到了问题</span></p>
          <div class="qphoto" style="margin-top:30px;">
              <span style="font-size:18px;display:inline-block;margin-bottom:20px;">问题图片:</span>
              <el-upload
                  action="https://jsonplaceholder.typicode.com/posts/"
                  list-type="picture-card"
                  :on-preview="handlePictureCardPreview"
                  :on-remove="handleRemove">
                  <i class="el-icon-plus"></i>
              </el-upload>
              <el-dialog :visible.sync="dialogVisible">
                  <img width="100%" :src="dialogImageUrl" alt="">
              </el-dialog>
          </div>
          <el-form ref="form" v-model="form" label-width="80px">
            <span style="font-size:18px;display:inline-block;margin-top:30px;">问题回答:</span>
            <el-form-item label="" >     
              <el-input type="textarea" v-model="form.answer" placeholder="在此输入回答的问题"></el-input>
            </el-form-item>
            </el-form>
          <el-button style="background:lightblue;margin-top:30px;" @click="qback" :addId="addId">确定回答并返回列表</el-button>
      </div>
      
    </div>
  </template>
  
  <script>
  import {getXmedicineList,getXmedicineAnswer} from '../../../api'
  export default {
      data() {
        return {
          // 图片上传
          dialogImageUrl: '',
          dialogVisible: false,
          form: {},
           addId:0
        };
      },
      created() {
        getXmedicineList(this.form).then(res => {
          console.log(res)
          this.form = res.data

        })
    },
      methods: {
          // 图片上传
          handleRemove(file, fileList) {
              console.log(file, fileList);
          },
          handlePictureCardPreview(file) {
              this.dialogImageUrl = file.url;
              this.dialogVisible = true;
          },
          qback() {
            console.log(this.form);
            getXmedicineAnswer(this.addId).then(res => {
              console.log(res);
              // this.$router.push('/Questions')
              this.addId = res.data.id
              console.log(addId)
            })
          }
      }
  }
  </script>
  
  <style>
  
  </style>